package product;

import java.io.Serializable;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class ProductData implements Serializable{
	String pCode,pName;
	int ea,cost,tot;
	Date nal;
	
	public ProductData(String pc, String pn, int eas, int cos, Date n){	// ProductInput&Update
		this.pCode=pc;
		this.pName=pn;
		this.ea=eas;
		this.cost=cos;
		this.nal=n;
		this.tot=ea*cost;		
	}
	
	public ProductData(String pc, String pn, int cos){			// CodeInput
		this.pCode=pc;
		this.pName=pn;		
		this.cost=cos;
		this.nal=new Date();		
	}
	
	public ProductData(String pc, String pn, int cos, Date n){			// Code Update 에서 수정시 날짜 초기화 방지용 생성자.
		this.pCode=pc;
		this.pName=pn;		
		this.cost=cos;
		this.nal=n;		
	}
	
	public String decimalFormat(){
		DecimalFormat df = new DecimalFormat("#,###,###");
		String str = df.format(tot);
		return str;
	}
	
	public String decimalFormat(int a){ // 매개변수 전달받아 포멧설정
		DecimalFormat df = new DecimalFormat("#,###,###");
		String str = df.format(a);
		return str;
	}
	
	public int getTot() {
		return tot;
	}

	public void setTot(int tot) {
		this.tot = tot;
	}
	
	public String getpCode() {
		return pCode;
	}

	public void setpCode(String pCode) {
		this.pCode = pCode;
	}

	public String getpName() {
		return pName;
	}

	public void setpName(String pName) {
		this.pName = pName;
	}

	public int getEa() {
		return ea;
	}

	public void setEa(int ea) {
		this.ea = ea;
	}

	public int getCost() {
		return cost;
	}

	public void setCost(int cost) {
		this.cost = cost;
	}

	public Date getNal() {
		return nal;
	}

	public void setNal(Date nal) {
		this.nal = nal;
	}

	
	
	@Override
	public String toString(){
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
		
		String temp = sdf.format(nal);
		String str = String.format("%-10s%-10s%-10s%-15s%-12s\n", pCode, pName, ea, cost, temp);
		
		return str;
	}
	
	
}
